<template>
	<view>
		<view class="uni-list">
		    <block v-for="(item,index) in res" :key="index">
		        <view class="uni-list-cell" hover-class="uni-list-cell-hover">
		            <view class="uni-triplex-row">
		                <view class="uni-triplex-left">
		                    <text class="uni-title uni-ellipsis" style="font-size: 28upx;padding: 0;"> {{item.title}}
														<text class="uni-title uni-ellipsis" style="font-size: 24upx;font-size: 24upx;padding-left: 20upx;"> 金额{{item.price}}</text>
												</text>
												
		                </view>
		            </view>
		        </view>
						<view style="display: flex;height: 180upx;flex-wrap: nowrap;" v-for="(good,index1) in item.goods" :key="index1">
							<view style="flex: 3;margin-left: 30upx;height: 100%;" >
								<view style="height: 80upx;line-height: 80upx;">
									{{good.title}}
								</view>
								<view style="height: 80upx;line-height: 80upx;color: #FF0000;">
									原价:{{good.marketprice}} 差价:{{good.difference}}
								</view>
							</view>
							<view style="flex: 1;" >
								<view style="width: 140upx;height: 52upx;line-height: 52upx;border-radius: 40upx;background-color: #FF5555;text-align: center;color: #fff;font-weight: 555;margin-top: 60upx;"  @click="upgrade(good.id,good.gift,item.id)">
									升级
								</view>
							</view>
						</view>
		    </block>
		</view>
		<view v-if="!res" style="padding-top: 300upx;">
			<image src="../../static/searchlist.png" mode="" style="display: block;margin: 0 auto;width: 240upx;height: 240upx;"></image>
			<view style="text-align: center;color: #999;">暂时没有任何记录</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				res:[],
				openid:'',
			};
		},
		onLoad:function(){
			uni.showLoading()
			uni.getStorage({
				key: 'openid',
				success: (res) => {
					this.openid = res.data
					this.setAjax()
				},
				fail: () => {
					uni.navigateTo({
						url: '../../login/login'
					});
				}
			});
		},
		methods:{
			setAjax(){
				uni.request({
					url: 'http://adkk.mygodmall.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=member.upgrade&app=1',
					method: 'POST',
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					data: {'openid':this.openid},
					success: res => {
						uni.hideLoading()
						this.res = res.data.result.list
						console.log(this.res)
					},
					fail: () => {},
					complete: () => {}
				});
				
			},
			upgrade (id,gift,orderid) {
				uni.request({
					url: 'http://adkk.mygodmall.com/app/index.php?i=4&c=entry&m=ewei_shopv2&do=mobile&r=order.create&app=1',
					method: 'POST',
					header:{'Content-Type':'application/x-www-form-urlencoded'},
					data: {
						'openid':this.openid,
						'id':id,
						'orderid':orderid,
						'gift':gift,
					},
					success: res => {
						uni.hideLoading()
						if (res.statusCode == 200) {
							uni.navigateTo({
								url: '../../pages/order/create/create?id=' + id + '&optionid=0&total=1' + '&orderid=' + orderid + '&gift=' + gift
							})
						}
					},
					fail: () => {},
					complete: () => {}
				});
			},
			jump(e){
				uni.navigateTo({
					url: e.currentTarget.dataset.src
				});
			},
		}
	}
</script>

<style>
	.btn-hover {
		background: #f2f2f2 !important;
	}
	.status{width:100%;font-size:24upx;background:#e0e0e0;text-align:center;color:#fff;margin-top:21upx;}</style>
